#ifndef _LIB_YLD_H__
#define _LIB_YLD_H__

#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>

typedef int (*fun)(int, int);

extern char expr[BUFSIZ];
extern char *expr_end;
extern int n_stack[BUFSIZ];
extern int *n_p;
extern int o_stack[BUFSIZ];
extern int *o_p;
extern enum TYPE {NUM, OPT, LPAR, RPAR} xxtype;
extern enum OPTT {ADD, SUB, MUL, DIV} xxoptt;
extern fun f[4];
extern int o2n[4];
extern int pri[4];

#define IS_OEMPTY       (o_p == o_stack)
#define PVAL            128
#define PUSHO(x)        (*o_p++ = x)
#define POPO(x)         ((o_p)==(o_stack)||((o_p[-1])==PVAL)? \
                        ((x) = (-1)):((x) = (*--o_p)))
#define PUSHN(x)        (*n_p++ = x)
#define POPN(x)         ((x) = (*--n_p))
#define CMPO(l, r)      (pri[l]-pri[r])
#define CALL            (*o_p++ = PVAL)
#define O2N(sym)        (!strcmp(sym, "+")? ADD:\
                        !strcmp(sym, "-")? SUB:\
                        !strcmp(sym, "*")? MUL: DIV)

#endif